package com.penjin.android.activity.secretary;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.easemob.util.NetUtils;
import com.loopj.android.http.RequestParams;
import com.loopj.android.http.TextHttpResponseHandler;
import com.penjin.android.R;
import com.penjin.android.constants.HttpConstants;
import com.penjin.android.http.HttpService;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONObject;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by lxl on 2016/4/4.
 */
public class listAdapter extends BaseAdapter {


    private Context context ;

    private List<Data> datas ;

    public listAdapter( Context context , List<Data> datas ){

        this.context = context ;
        this.datas = datas ;

    }


    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View view = LayoutInflater.from(context).inflate(R.layout.test_pushlist_item,null) ;
        TextView id = (TextView) view.findViewById(R.id.test_pushlist_item_id);
        final TextView content = (TextView) view.findViewById(R.id.test_pushlist_item_content);

        final Data data = (Data) getItem(position);

        id.setText(data.getTitle());
        content.setText(data.getContent());

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(context,testPushListActivity.class) ;

                intent.putExtra("id",data.getId()) ;

                context.startActivity(intent);

            }
        });

        return view;
    }


}
